/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
angular.module("patientList", ['ui.bootstrap'])
        .controller("mainController", function($scope) {

            var so = $scope;
            $scope.data = {currentPage: 1};
            so.setPage = function(pageNo) {
                $scope.data.currentPage = pageNo;
            };

            so.pageChanged = function() {
                so.getList();
            };

            so.data.maxSize = 10;
            so.data.bigTotalItems = 20;
            so.data.bigCurrentPage = 1;
            so.data.pageSize = 10;

            so.getList = function() {
                $.post("getPatientList",{content:so.searchContent,pageSize: so.data.pageSize, currentPage: so.data.currentPage}, function(data) {
                   
                    if(data){
                    so.lists = data.list;
                    so.data.bigTotalItems = data.totalRow;
                    if (so.lists) {
                        for ( var i in so.lists) {
                            if (so.lists[i].pat_sex == 'F') {
                                so.lists[i].pat_sex = "男";
                            } else {
                                so.lists[i].pat_sex = "女";
                            }
                        }
                    }
                    so.$apply();
                }
                });
            }
            so.restart = function(client) {
                $.post("sendCommond", {to: client.loginId, commond: "restart"}, function(data) {
                    if (data == 'true') {
                        steveAl("发送成功");
                    } else {
                        steveAl("发送失败");
                    }
                })
            }
            so.sendMore = function(){
                var morePks = [];
                 for( var i in  so.lists ) {                   
                     if(so.lists[i].send){
                         morePks.push(so.lists[i].pk);
                         
                     }
                    
                 }
                 if(morePks.length>0){
                     steveConfrim("确定发送到中心吗？",function(){
                         $.cxhd.loading();
                         $.post("sendCenter",{pks:morePks.join(",")},function(data){
                             if(data=='true'){
                                 steveAl("正在发送",1000);
                             }else{
                                 steveAl("发送失败",1000)
                             }
                         })
                     },true)
                 }
            }
            so.getList();

        })


